<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!DOCTYPE html>
<html lang="zh">
<fmt:bundle basename="charts">
    <head>
        <meta charset="utf-8"/>
        <title>报表总览</title>
        <%-- rem.js --%>
        <script>if ('${auth}' != '') {localStorage.setItem('auth', ${auth});if (localStorage.getItem('auth')==0) location.href="<%=basePath%>";}</script>
        <script src="<%=basePath%>/js/rem.js"></script>
        <link rel="shortcut icon" href="<%=basePath%>/images/favicon.ico">
        <link rel="stylesheet" href="<%=basePath%>/plugins/charts/css/global.css"/>
        <link rel="stylesheet" href="<%=basePath%>/bootstrap/css/bootstrap.min.css">
        <link rel="stylesheet" href="<%=basePath%>/bootstrapvalidator/css/bootstrapValidator.min.css">
        <link rel="stylesheet" href="<%=basePath%>/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/select2/select2.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/viewer/viewer.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/iCheck/all.css">
        <link rel="stylesheet" href="<%=basePath%>/css/font-awesome.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/iziModal/css/iziModal.min.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/charts/css/style.css"/>
        <link rel="stylesheet" href="<%=basePath%>/plugins/flavr/flavr.css">
        <link rel="stylesheet" href="<%=basePath%>/fileupload/fileinput.min.css" type="text/css" />
        <link rel="stylesheet" href="<%=basePath%>/plugins/jquery-chat/css/jquery.chat.css">
        <link rel="stylesheet" href="<%=basePath%>/css/score.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/thumbnail/css/thumbnail.css">
        <link rel="stylesheet" href="<%=basePath%>/plugins/raty/jquery.raty.css">
        <%-- 保养评分模态框样式 --%>
        <style>
            .new-title a:hover {
                cursor: text;
                text-decoration: none;
            }
        </style>
    </head>
    <body>


    <div id="container">
            <%--顶部选项--%>
        <div class="head-container">
            <div class="head">
                <div class="fl">
                    <h1 id="hospital-name" style="position: absolute;left: 0;font-size: 0.4rem;color:#fff;margin:0;line-height: 1.2rem;"></h1>
                </div>
                <div class="fl global_area">
                    <ul class="global" style="margin-left:-5.0rem;">
                        <li><a id="btn1" style="display: block;" class="on"><fmt:message key="share.title.zl"/></a></li>
                        <li><a id="btn2"><span class="page" page-hospital="department-index"><fmt:message key="share.title.fx"/></span></a></li>
                        <li><a id="btn6" onclick="reset()"><img src="<%=basePath%>/plugins/charts/images/reset.png"></a></li>
                        <li><a id="btn7" onclick="logout()" title="<fmt:message key="share.title.tcdl"/>"><img src="<%=basePath%>/plugins/charts/images/logout.png"></a></li>
                    </ul>
                </div>
                <div class="weather fr">
                    <div class="fl weather-img"></div>
                    <div class="fl">
                        <p class="date"></p>
                        <p class="weather-info"></p>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>

        <div class="col-md-12 content" style="height: calc(100% - 1.2rem);color:#fff;">
            <%-- 左侧部分 --%>
            <div class="col-md-7" style="height:100%;padding:0;position: relative;">
                <%-- 每条维修记录的气泡图 --%>
                <%--<div id="repairBtn" style="border:1px solid #fff;border-radius:4px;position: absolute;z-index: 11;top: 10px; right: 10px;padding: 2px 5px;cursor:pointer;"
                     onclick="javascript:(function(){if($('#repairBtn').hasClass('active')){$('#chartRepair').css('z-index', 0);$('#repairBtn').removeClass('active');}else{$('#chartRepair').css('z-index', 10);$('#repairBtn').addClass('active');}})();">维修记录</div>
                <div id="chartRepair" style="width: 100%;height: 100%;position: absolute;top: 0;left:0;background: rgb(55, 57, 69);z-index: 0;"></div>--%>
                <div class="bb2 col-md-12">
                    <div class="col-md-12">
                        <h4 class="bold">设备情况分析</h4>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-2" id="deviceCountPrice" style="padding: 0 0.3rem 0 0; display: flex;flex-direction: column;justify-content:flex-end">
                            <p class="item">设备数量</p>
                            <p class="value spanTitle" id="deviceCount">0台</p>
                            <div class="line-dashed"></div>
                            <p class="item">设备金额</p>
                            <p class="value" id="devicePrice">0万元</p>
                            <div class="line-dashed"></div>
                            <p class="item">折旧率</p>
                            <p class="value" id="deviceDepreciationRatio">0%</p>
                        </div>
                        <div class="col-md-4">
                            <div id="chartCost" style="height: 2.0rem;width:130%;"></div>
                            <div style="width:120%;overview: hidden;">
                                <p class="item layout fl" style="width: 60%;padding-right:0.12rem;"><span>累计收入(年)</span><span class="value fr" id="income">0万元</span><span class="clearfix"></span></p>
                                <p class="item layout fl" style="width: 40%;padding-left:0.12rem;"><span>同比</span><img class="fr" src="<%=basePath%>/plugins/charts/images/arrow_zero.png" style="height:1.2em;vertical-align: middle;"/><span class="value fr" id="incomeYoy">0%</span><span class="clearfix"></span></p>
                            </div>
                            <div style="width:120%;overview: hidden;">
                                <p class="item layout fl" style="width: 60%;padding-right:0.12rem;"><span>累计支出(年)</span><span class="value fr" id="expenditure">0万元</span><span class="clearfix"></span></p>
                                <p class="item layout fl" style="width: 40%;padding-left:0.12rem;"><span>同比</span><img class="fr" src="<%=basePath%>/plugins/charts/images/arrow_zero.png" style="height:1.2em;vertical-align: middle;"/><span class="value fr" id="expenditureYoy">0%</span><span class="clearfix"></span></p>
                            </div>
                        </div>
                        <div class="col-md-3" style="padding-right: 0;">
                            <div id="chartServiceTime" style="height: 2.0rem;margin-left:20%;"></div>
                            <div class="fr" style="width:80%;">
                                <p class="item layout"><span>累计故障次数(年)</span><span class="value fr spanTitle" id="serviceTime">0</span><span class="clearfix"></span></p>
                                <p class="item layout" style="padding-top:0.04rem;"><span>当年故障率</span><span class="value fr" id="faultTime">0%</span><span class="clearfix"></span></p>
                            </div>
                        </div>
                        <div class="col-md-3" style="padding-right: 0;">
                            <div id="chartServicePerson" style="height: 2.0rem;"></div>
                            <div  style="width:80%;margin:0 auto;">
                                <p class="item layout"><span>累计人次(年)</span><span class="value fr" id="servicePerson">0</span><span class="clearfix"></span></p>
                                <p class="item layout fl" style="padding-top:0.04rem;"><span>同比</span><img class="fr" src="<%=basePath%>/plugins/charts/images/arrow_zero.png" style="height:1.2em;vertical-align: middle;"/><span class="value fr" id="servicePersonYoy">0%</span><span class="clearfix"></span></p>
                            </div>
                        </div>

                        <div class="col-md-12 line-solid"></div>
                    </div>
                    <div class="col-md-12 year-month">
                        <div class="col-md-6">
                            <h4 class="text-center">年度统计</h4>
                        </div>
                        <div class="col-md-3">
                            <h4 class="text-center">当月统计</h4>
                        </div>
                        <div class="col-md-3">
                            <h4 class="text-center">负荷率统计</h4>
                        </div>
                        <%-- 年度统计 --%>
                        <div class="col-md-6" style="height:100%;">
                            <div id="chartYear" style="height:100%;"></div>
                        </div>

                        <%-- 当月统计 --%>
                        <div class="col-md-3" style="height:100%;">
                            <div class="month">
                                <div class="month-value fl">
                                    <span class="value">100%</span>
                                    <p class="circle-line"><span></span></p>
                                    <span class="name">巡检</span>
                                </div>
                                <div class="month-chart fr"></div>
                            </div>
                            <div class="month">
                                <div class="month-value fl">
                                    <span class="value">100%</span>
                                    <p class="circle-line"><span></span></p>
                                    <span class="name">强检</span>
                                </div>
                                <div class="month-chart fr"></div>
                            </div>
                            <div class="month">
                                <div class="month-value fl">
                                    <span class="value">100%</span>
                                    <p class="circle-line"><span></span></p>
                                    <span class="name">保养</span>
                                </div>
                                <div class="month-chart fr"></div>
                            </div>
                            <div class="month">
                                <div class="month-value fl">
                                    <span class="value">100%</span>
                                    <p class="circle-line"><span></span></p>
                                    <span class="name">维修</span>
                                </div>
                                <div class="month-chart fr"></div>
                            </div>
                        </div>
                        <%-- 分类统计 --%>
                        <div class="col-md-3" style="height:100%;">
                            <div id="chart-open" style="height:100%;"></div>
                        </div>
                    </div>

                    <div id="list-model" class="col-md-12" style="padding:0.1rem 0.2rem;">
                        <div style="border-bottom: 2px solid #8d8f9b;">
                            <h4 id="list-title" class="bold fl model-title">紧急维修</h4>
                            <i class="fa fa-times fr" id="list-close"></i>
                            <i class="fa fa-upload fr export_excel" onclick="exportExcel('#list-model')" id="list-export"></i>
                            <div class="clearfix"></div>
                        </div>
                        <div style="width: 100%;height:calc(100% - 0.8rem);overflow:auto;">
                            <table id="list-table1" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table2" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table3" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table4" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table5" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table6" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                            <table id="list-table7" class="list-table" style="display: none;">
                                <thead></thead>
                                <tbody></tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <%-- 右侧部分 --%>
            <div class="col-md-5" style="height:100%;padding-right: 0;">
                <div class="bb2 col-md-12">
                    <div id="asset-model" style="padding:0.1rem 0.2rem;height: calc(100% + 0.3rem);overflow: hidden;margin-bottom: 0.4rem;display:none;">
                        <div style="border-bottom: 2px solid #8d8f9b;">
                            <h4 id="asset-title" class="bold fl model-title">维修详情</h4>
                            <i class="fa fa-times fr" id="asset-close"></i>
                            <i class="fa fa-upload fr export_excel" onclick="exportExcel('#asset-model')" id="asset-export"></i>
                            <div class="clearfix"></div>
                        </div>
                        <div style="width: 100%;height:calc(100% - 0.8rem);overflow:auto;">
                            <table id="asset-table" class="list-table">
                                <thead></thead>
                                <tbody></tbody>
                                <tfoot></tfoot>
                            </table>
                        </div>
                    </div>

                    <div class="col-md-12 warning-title">
                        <h4 class="bold fl">
                            <img class="fl" style="margin:-0.04rem 0.1rem 0 0;width:0.48rem;height:0.48rem;" src="<%=basePath%>/plugins/charts/images/web/info.png">
                            警示事项
                        </h4>
                    </div>
                    <div class="col-md-12 warning-icon" style="padding-top: 0.2rem;display: flex;flex-direction: row;justify-content: space-between;">
                        <div class="icon-frame">
                            <span id="exigencyRepair" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/repair.png">
                            <p class="word">紧急维修</p>
                        </div>
                        <div class="icon-frame">
                            <span id="highRiskRepair" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/hitch.png">
                            <p class="word">择期维修</p>
                        </div>
                        <div class="icon-frame">
                            <span id="planCompulsory" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/force.png">
                            <p class="word">强检提醒</p>
                        </div>
                        <div class="icon-frame">
                            <span id="recall" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/recall.png">
                            <p class="word">召回事件</p>
                        </div>
                        <div class="icon-frame">
                            <span id="planInspection" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/monitor.png">
                            <p class="word">设备监控</p>
                        </div>
                        <div class="icon-frame">
                            <span id="planUpkeep" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web-icon/upkeep.png">
                            <p class="word">保养提醒</p>
                        </div>
                        <div class="icon-frame">
                            <span id="planSchedule" class="tip">0</span>
                            <img class="icon" src="<%=basePath%>/plugins/charts/images/web/info.png">
                            <p class="word">待办事项</p>
                        </div>
                    </div>
                    <div class="col-md-12 warning-list" style="margin: 0.2rem 0;">
                        <div style="overflow:hidden;">
                            <ul class="alert-list"></ul>
                        </div>
                        <div style="overflow:hidden;">
                            <ul class="repair-list"></ul>
                        </div>
                        <div style="overflow: hidden;">
                            <ul class="other-list"></ul>
                        </div>
                        <div style="overflow: hidden;display: none;">
                            <ul class="change-list"></ul>
                        </div>
                    </div>


                    <div class="col-md-12 line-solid border-box" style="margin: 0 0.3rem 0.3rem;width: calc(100% - 0.6rem);"></div>
                    <%-- 事件提醒 --%>
                    <div class="col-md-12 new-title">
                        <h4 class="bold fl">
                            <img class="fl" style="margin: -0.04rem 0.1rem 0 0;width: 0.48rem;height: 0.48rem;" src="<%=basePath%>/plugins/charts/images/web/hyzx.png">
                            事件提醒
                        </h4>
                        <a class="fr" style="line-height: 0.8rem;color: #fff;">更多>></a>
                    </div>
                    <div class="col-md-12" style="overflow: hidden;">
                        <ul class="chat-list"></ul>
                    </div>
                    <div class="col-md-12 event-list">
                        <ul class="new-list">
                            <li>
                                <i></i>
                                <a href="#">美敦力、强生、贝朗、巴德等8家械企主动申请耗材降价！</a>
                                <span>2018-01-19</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">科技部长点名医疗器械：要国产化、高端化！</a>
                                <span>2018-01-18</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">药监、卫计联手！10种医械企业禁止参加招标采购</a>
                                <span>2018-01-17</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">2017医学装备售后服务满意度调查结果</a>
                                <span>2018-01-16</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">上海自贸区“证照分离”有了升级版 医疗器械注册证试行</a>
                                <span>2018-01-15</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">发改委发文：这几类器械和药物将获重点支持</a>
                                <span>2018-01-14</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">AI医疗有多火？强生全线进军AI领域，研发外科手术机器人</a>
                                <span>2018-01-13</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">设备故障 通用电气医疗系统公司主动召回麻醉机</a>
                                <span>2018-01-12</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">康蒂思(上海)医疗器械有限公司对镍钛支架系统主动召回</a>
                                <span>2018-01-11</span>
                            </li>
                            <li>
                                <i></i>
                                <a href="#">西门子主动召回X射线计算机体层摄影设备 涉及美国等国家</a>
                                <span>2018-01-10</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <%-- 聊天 --%>
    <div id="chat-box" style="width: 16.0rem;height: 12.0rem;position: fixed;z-index: 99999;top: 50%;left: 50%;margin: -6.0rem 0 0 -8.0rem;text-align: left;display: none;"></div>

    <%-- JS部分 --%>
    <script src="<%=basePath%>/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="<%=basePath%>/plugins/iziModal/js/iziModal.min.js"></script>
    <script src="<%=basePath%>/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=basePath%>/plugins/fastclick/fastclick_1.0.6.min.js"></script>
    <script src="<%=basePath%>/bootstrap/js/bootstrap.min.js"></script>
    <script src="<%=basePath%>/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
    <script src="<%=basePath%>/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script src="<%=basePath%>/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="<%=basePath%>/fileupload/fileinput.min.js"></script>
    <script src="<%=basePath%>/fileupload/zh.js"></script>
    <script src="<%=basePath%>/plugins/select2/select2.full.min.js"></script>
    <script src="<%=basePath%>/plugins/select2/i18n/zh-CN.js"></script>
    <script src="<%=basePath%>/plugins/flavr/flavr.min.js"></script>
    <script src="<%=basePath%>/plugins/jQuery/jquery.cookie.js"></script>
    <script src="<%=basePath%>/plugins/viewer/viewer.min.js"></script>
    <script src="<%=basePath%>/plugins/vticker/jquery.vticker.min.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/echarts.min.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/plugins.js"></script>
    <script src="<%=basePath%>/plugins/charts/js/tableHeadFixer.js"></script>
    <script src="<%=basePath%>/js/upkeepScore.js"></script>
    <script src="<%=basePath%>/js/repairScore.js"></script>
    <script src="<%=basePath%>/js/appoint.js"></script>
    <script src="<%=basePath%>/js/echarts-option.js"></script>
    <script src="<%=basePath%>/js/websocket-report.js"></script>
    <script src="<%=basePath%>/js/websocket-chat.js"></script>
    <script src="<%=basePath%>/js/eventAlert.js"></script>
    <script src="<%=basePath%>/js/canshu.js"></script>
    <script src="<%=basePath%>/js/hospital/iziModal-repair.js"></script>
    <script src="<%=basePath%>/plugins/wangEditor/wangEditor.min.js"></script>
    <script src="<%=basePath%>/plugins/jquery-chat/js/jquery.chat.js"></script>
    <script src="<%=basePath%>/plugins/thumbnail/js/thumbnail.js"></script>
    <script src="<%=basePath%>/plugins/raty/jquery.raty.js"></script>
    <script>
        webSocketReport(${userId}, ${hospitalId});
        /*--------- 全局变量 ---------*/
        var rem = parseInt($('html').css('font-size'));
        var CONST = 1000000;
        var basePath = '<%=basePath%>';
        var selectedColor = '#0072b9';
        var chartCostEl = $('#chartCost');
        var chartServiceTimeEl = $('#chartServiceTime');
        var chartServicePersonEl = $('#chartServicePerson');
        var monthChart = $('.month-chart');
        var chartOpenEl = $('#chart-open');
        var waringLis = {1:{status:false,list:{daiban:{},other:{},gaowei:{}}},2:{status:false,list:[]},3:{status:false,list:[]},4:{status:false,list:[]},5:{status:false,list:[]},6:{status:false,list:[]},7:{status:false,list:[]}};

        var newListTimer = null;
        var newList = $('.new-list');


        chartCostEl.height(chartServiceTimeEl.width());
        chartServiceTimeEl.height(chartServiceTimeEl.width());
        chartServicePersonEl.height(chartServiceTimeEl.width());
        $('#deviceCountPrice').height($('#deviceCountPrice').parent().height() - 10);
        var yearMonth = $('.year-month');
        yearMonth.height(yearMonth.parent().height() - yearMonth.siblings().eq(0).height() - yearMonth.siblings().eq(1).height() - 40);
        var month = $('.month');
        month.height(month.parent().height() / 4).css('padding', '0.16rem 0');
        month.find('.month-chart').css('height', '100%').width(month.find('.month-chart').height());
        month.find('.month-value').css('height', '100%').width(month.width() - month.find('.month-chart').width() - 3);
        var warningList = $('.warning-list');
        var alertList = $('.alert-list');
        var eventList = $('.event-list');
        var totalHeight = warningList.parent().height() - $('.warning-title').height() - $('.warning-icon').height() - $('.new-title').height() - 35;
        var totalCount = parseInt(totalHeight / (rem * 0.8));
        eventList.height((rem * 0.8) * parseInt(totalCount / 2));
        var warningCount = totalCount - parseInt(totalCount / 2);
        warningList.height((rem * 0.8) * warningCount);
        var changeList = $('.change-list');
        changeList.parent().height(warningList.height());
        var changeCount = 0;
        var changeTimer = null;
        var repairList = $('.repair-list');
        var otherList = $('.other-list');
        var chatList = $('.chat-list');

        var chartCost = echarts.init(chartCostEl[0]);
        var chartServiceTime = echarts.init(chartServiceTimeEl[0]);
        var chartServicePerson = echarts.init(chartServicePersonEl[0]);
        chartCost.on('click', click);
        chartServiceTime.on('click', click);
        chartServicePerson.on('click', click);

        var chartYear = echarts.init($('#chartYear')[0]);
        chartYear.on('click', clickYear);
        var chartMonth0 = echarts.init(monthChart[0]);
        var chartMonth1 = echarts.init(monthChart[1]);
        var chartMonth2 = echarts.init(monthChart[2]);
        var chartMonth3 = echarts.init(monthChart[3]);
        var chartOpen = echarts.init(chartOpenEl[0]);
        chartOpen.on('click', click);

        var servicePerson = getRandom(234, 512, 'int');
        var lastServicePerson = getRandom(1000, 1500, 'int');
        var param = {
            name: '',
            typeId: '',
            dataIndex: '',
            loading: true
        };
        /*--------- 全局变量 ---------*/
        loading();
        /* 获取天气 */
        var weatherEl = $('.weather');
        weatherEl.find('.date').html(getDate().date + '    ' + getDate().week());
        publicAjax(basePath + '/charts/hospital/overview/weather', 'post', '', function (data) {
            if (data.ret) {
                weatherEl.find('.weather-img').html(getWeatherImg(data.data.stateDetailed));
                weatherEl.find('.weather-info').html(data.data.cityname + '    ' + data.data.tem2 + '~' + data.data.tem1 + '℃    ' + data.data.stateDetailed);
            }
        }, true);
        /* 获取医院名，省市区 */
        publicAjax(basePath + '/charts/hospital/overview/region', 'post', '', function (data) {
            if (data.ret) {
                $('#hospital-name').html(data.data.hospital + '设备管理云');
            }
        }, true);

        var initStatus = {
            detailStatus: {
                queryDeviceBaseInfo: false,
                queryDevicePerformanceInfo: false,
                queryDeviceFaultInfo: false,
                queryDevicePersonInfo: false,
                queryYearTotal: false,
                queryMonthTotal: false,
                queryUsageRate: false,
                queryWarning: false,
                queryWarningList1: false,
                queryWarningList2: false,
                queryWarningList3: false,
                queryWarningList4: false,
                queryWarningList5: false,
                queryWarningList6: false,
                queryWarningList7: false,
                queryNewList: false
            },
            getStatus: function () {
                var status = false;
                for (var key in this.detailStatus) {
                    if(this.detailStatus[key] === true) {
                        status = true;
                    } else {
                        return false;
                    }
                }
                return status;
            },
            setFalse: function () {
                for (var key in this.detailStatus) {
                    this.detailStatus[key] = false;
                }
            }
        };

        init();
        initBindEvent();
        setInterval(init, 1000 * 60 * 10);

        function init(parameters) {
            loading();
            queryDeviceBaseInfo(parameters);
            queryDevicePerformanceInfo(parameters);
            queryDeviceFaultInfo(parameters);
            queryDevicePersonInfo(parameters);
            queryYearTotal(parameters);
            queryMonthTotal(parameters);
            queryUsageRate(parameters);
            queryWarning(parameters);
            queryWarningList(1, parameters);
            queryWarningList(2, parameters);
            queryWarningList(3, parameters);
            queryWarningList(4, parameters);
            queryWarningList(5, parameters);
            queryWarningList(6, parameters);
            queryWarningList(7, parameters);
            queryNewList(parameters);
        }

        /* 图表点击 */
        function click(parameters) {
            // 如果是饼图的大中小维修 return
            if (parameters.seriesType === 'pie' && parameters.seriesIndex === 1) return;
            loading();
            if (initStatus.getStatus()) {
                setTimeout(function () {
                    initStatus.setFalse();
                    var newOptionCost = $.extend(true, {}, optionCost);
                    var newOptionServiceTime = $.extend(true, {}, optionServiceTime);
                    var newOptionServicePerson = $.extend(true, {}, optionServicePerson);
                    var newOptionOpen = $.extend(true, {}, optionOpen);
                    var index = '';
                    if (parameters.name === '收入') {
                        index = parameters.seriesIndex;
                    } else {
                        loading(true);
                        return;
                        index = parameters.dataIndex;
                    }
                    if (param.dataIndex === index || (parameters.seriesType === 'pie' && parameters.event.target.__normalStl.text)) {
                        param.dataIndex = false;
                        param.name = '';
                        param.typeId = '';
                    } else {
                        /* 设置参数 */
                        param.dataIndex = index;
                        param.name = faultJson[param.dataIndex].name;
                        param.typeId = faultJson[param.dataIndex].id;
                        /* 设置选中样式 */
                        newOptionCost.series[param.dataIndex].itemStyle.normal.color = selectedColor;

                        newOptionServiceTime.series[0].data[param.dataIndex].selected = true;
                        newOptionServiceTime.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;
                        newOptionServicePerson.series[0].data[param.dataIndex].selected = true;
                        newOptionServicePerson.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;
                        newOptionOpen.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;

                        newOptionServiceTime.series[0].label.normal.formatter = function (params) {
                            if (params.dataIndex === 2) {
                                return faultJson[param.dataIndex].name;
                            } else if (params.dataIndex === 4) {
                                return (faultJson[param.dataIndex].curToRepairCounts || 0) + '次';
                            } else {
                                return '';
                            }
                        };
                        newOptionServicePerson.series[0].label.normal.formatter = function (params) {
                            if (params.dataIndex === 2) {
                                return faultJson[param.dataIndex].name;
                            } else if (params.dataIndex === 4) {
                                return (optionServicePerson.series[0].data[param.dataIndex].value || 0) + '次';
                            } else {
                                return '';
                            }
                        };
                    }
                    $('#asset-model').hide();
                    chartCost.setOption(newOptionCost);
                    chartServiceTime.setOption(newOptionServiceTime);
                    chartServicePerson.setOption(newOptionServicePerson);
                    chartOpen.setOption(newOptionOpen);
                    init(param);
                }, 200);
            } else {
                loading(true);
            }
        }

        /* 年度统计图表点击 */
        function clickYear(parameters) {
            $('#asset-model').show();
            queryYearAssets($.extend({}, param, {dateType: 1,statisticsType:parameters.seriesIndex}));
        }

        /* 设备情况分析 */
        function queryDeviceBaseInfo(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/base', 'post', param, function (data) {
                if (data.ret) {
                    /* 设备数量 和 设备金额 */
                    numAnimate({
                        el: $('#deviceCount'),
                        newNum: parseFloat(data.data.base.deviceCounts),
                        unit: '台'
                    });
                    numAnimate({
                        el: $('#devicePrice'),
                        newNum: data.data.base.devicePrice / CONST,
                        fixNum: 2,
                        unit: '万元'
                    });
                    numAnimate({
                        el: $('#deviceDepreciationRatio'),
                        newNum: data.data.base.depreciationRatio,
                        fixNum: 2,
                        unit: '%'
                    });
                }
                initStatus.detailStatus.queryDeviceBaseInfo = true;
            }, true);
        }

        /* 绩效图表 */
        function queryDevicePerformanceInfo(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/performance', 'post', {}, function (data) {
                if (data.ret) {
                    performanceJson = data.data.performance;
                    /* 支出收入柱状图 */
                    numAnimate({
                        el: $('#expenditure'),
                        newNum: performanceJson.curExpenditure / CONST,
                        fixNum: 2,
                        unit: '万元'
                    }, resizeLayout);
                    numAnimate({
                        el: $('#income'),
                        newNum: performanceJson.curIncome / CONST,
                        fixNum: 2,
                        unit: '万元'
                    }, resizeLayout);
                    var expenditureYoyEl = $('#expenditureYoy');
                    numAnimate({
                        el: expenditureYoyEl,
                        newNum: Math.abs(performanceJson.expenditureYoy),
                        fixNum: 2,
                        unit: '%'
                    }, resizeLayout);
                    if (performanceJson.expenditureYoy > 0) {
                        expenditureYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_up.png');
                    } else if (performanceJson.expenditureYoy < 0) {
                        expenditureYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_down.png');
                    } else {
                        expenditureYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_zero.png');
                    }
                    var incomeYoyEl = $('#incomeYoy');
                    numAnimate({
                        el: incomeYoyEl,
                        newNum: Math.abs(performanceJson.incomeYoy),
                        fixNum: 2,
                        unit: '%'
                    }, resizeLayout);
                    if (performanceJson.incomeYoy > 0) {
                        incomeYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_up.png');
                    } else if (performanceJson.incomeYoy < 0) {
                        incomeYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_down.png');
                    } else {
                        incomeYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_zero.png');
                    }
                    performanceList = data.data.list;
                    if (performanceJson.curExpenditure > performanceJson.curIncome) {
                        for(var i = 0; i < performanceList.length; i++) {
                            /* 收入 */
                            optionCost.series[i].data[1] = 60 * (performanceList[i].curIncome/performanceJson.curIncome);
                            /* 支出 */
                            optionCost.series[7].data[0] = 30;
                            optionCost.series[8].data[0] = 10;
                            optionCost.series[9].data[0] = 40;
                            optionCost.series[10].data[0] = 20;
                        }
                    } else if (performanceJson.curExpenditure === performanceJson.curIncome) {
                        for(var i = 0; i < performanceList.length; i++) {
                            /* 收入 */
                            optionCost.series[i].data[1] = 100 * (performanceList[i].curIncome/performanceJson.curIncome);
                            /* 支出 */
                            optionCost.series[7].data[0] = 30;
                            optionCost.series[8].data[0] = 10;
                            optionCost.series[9].data[0] = 40;
                            optionCost.series[10].data[0] = 20;
                        }
                    } else {
                        for(var i = 0; i < performanceList.length; i++) {
                            /* 收入 */
                            optionCost.series[i].data[1] = 100 * (performanceList[i].curIncome/performanceJson.curIncome);
                            /* 支出 */
                            optionCost.series[7].data[0] = 18;
                            optionCost.series[8].data[0] = 6;
                            optionCost.series[9].data[0] = 24;
                            optionCost.series[10].data[0] = 12;
                        }
                    }
                    /* 如果收入最后一个柱子为0，设置前一个柱子圆角 */
                    var newOptionCost = $.extend(true, {}, optionCost);
                    for(var i = performanceList.length - 1; i > 0; i--) {
                        if (fix2(performanceList[i].curIncome / CONST) <= 0) {
                            newOptionCost.series[i - 1].itemStyle.normal.barBorderRadius = [0, 200, 200, 0];
                        } else {
                            break;
                        }
                    }
                    if (typeof param.dataIndex === 'number') {
                        newOptionCost.series[param.dataIndex].itemStyle.normal.color = selectedColor;
                    }
                }
                chartCost.setOption(newOptionCost);
                initStatus.detailStatus.queryDevicePerformanceInfo = true;
            }, true);
        }

        /* 运行时间 */
        function queryDeviceFaultInfo(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/avg-fault-rate', 'post', param, function (data) {
                if (data.ret) {
                    /* 运行时间 */
                    curToRepairCounts = data.data.all.curToRepairCounts;
                    numAnimate({
                        el: $('#serviceTime'),
                        newNum: parseFloat(data.data.all.curToRepairCounts),
                        fixNum: 0,
                        unit: ''
                    }, resizeLayout);
                    numAnimate({
                        el: $('#faultTime'),
                        newNum: parseFloat(data.data.all.curAvgFaultRate),
                        fixNum: 2,
                        unit: '%'
                    }, resizeLayout);

                    faultJson = data.data.list;
                    var list = data.data.list;
                    for (var i = 0; i < list.length; i++) {
                        optionServiceTime.series[0].data[i].name = list[i].name;
                        optionServiceTime.series[0].data[i].value = list[i].curToRepairCounts;
                    }
                    optionServiceTime.series[1].data[0].value = data.data.maintainSize.bigRepairCounts;
                    optionServiceTime.series[1].data[1].value = data.data.maintainSize.middleRepairCounts;
                    optionServiceTime.series[1].data[2].value = data.data.maintainSize.smallRepairCounts;
                }
                var newOption = $.extend(true, {}, optionServiceTime);
                if (typeof param.dataIndex === 'number') {
                    newOption.series[0].data[param.dataIndex].selected = true;
                    newOption.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;
                    newOption.series[0].label.normal.formatter = function (params) {
                        if (params.dataIndex === 2) {
                            return faultJson[param.dataIndex].name;
                        } else if (params.dataIndex === 4) {
                            return (faultJson[param.dataIndex].curToRepairCounts || 0) + '';
                        } else {
                            return '';
                        }
                    };
                }
                chartServiceTime.setOption(newOption);
                initStatus.detailStatus.queryDeviceFaultInfo = true;
            }, true);
        }

        /* 使用人次 */
        function queryDevicePersonInfo(parameters) {

        }

        /* 年度统计 */
        function queryYearTotal(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/maintenance-year', 'post', param, function (data) {
                var inspectionRate = 0;
                var compulsoryRate = 0;
                var upkeepRate = 0;
                var repairRate = 0;
                if (data.ret) {
                    inspectionRate = data.data.inspectionRate || 0;
                    compulsoryRate = data.data.compulsoryRate || 0;
                    upkeepRate = data.data.upkeepRate || 0;
                    repairRate = data.data.repairRate || 0;
                    YearJson = data.data;
                }
                optionYear.series[0].data[0].value = inspectionRate;
                optionYear.series[1].data[0].value = compulsoryRate;
                optionYear.series[2].data[0].value = upkeepRate;
                optionYear.series[3].data[0].value = repairRate;
                optionYear.series[0].data[1].value = 120 - inspectionRate;
                optionYear.series[1].data[1].value = 120 - compulsoryRate;
                optionYear.series[2].data[1].value = 120 - upkeepRate;
                optionYear.series[3].data[1].value = 120 - repairRate;

                /* 设置legend位置 */
                var bottom = 10;
                var height = $('#chartYear').height();
                var width = $('#chartYear').width();
                if (height > width) {
                    bottom += ((height - width) * 0.5);
                }
                optionYear.legend.bottom = bottom;

                chartYear.setOption(optionYear);
                initStatus.detailStatus.queryYearTotal = true;
            }, true);
        }

        /* 月份统计 */
        function queryMonthTotal(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/maintenance-month', 'post', param, function (data) {
                var inspectionRate = 0;
                var compulsoryRate = 0;
                var upkeepRate = 0;
                var repairRate = 0;
                if (data.ret) {
                    inspectionRate = data.data.inspectionRate || 0;
                    compulsoryRate = data.data.compulsoryRate || 0;
                    upkeepRate = data.data.upkeepRate || 0;
                    repairRate = data.data.repairRate || 0;
                }
                var option1 = $.extend(true, {}, optionMonth);
                var option2 = $.extend(true, {}, optionMonth);
                var option3 = $.extend(true, {}, optionMonth);
                var option4 = $.extend(true, {}, optionMonth);
                option1.series[2].data[0].value = inspectionRate;
                option1.tooltip.formatter = '实际巡检数：' + fix0(data.data.actualInspectionCounts) + '<br/>' +
                    '计划巡检数：' + fix0(data.data.planInspectionCounts) + '<br/>' +
                    '巡检完成率：' + fix2(inspectionRate) + '%';
                option2.series[2].data[0].value = compulsoryRate;
                option2.tooltip.formatter = '实际强检数：' + fix0(data.data.actualCompulsoryCounts) + '<br/>' +
                    '计划强检数：' + fix0(data.data.planCompulsoryCounts) + '<br/>' +
                    '强检完成率：' + fix2(compulsoryRate) + '%';
                option3.series[2].data[0].value = upkeepRate;
                option3.tooltip.formatter = '实际保养数：' + fix0(data.data.actualUpkeepCounts) + '<br/>' +
                    '计划保养数：' + fix0(data.data.planUpkeepCounts) + '<br/>' +
                    '保养完成率：' + fix2(upkeepRate) + '%';
                option4.series[2].data[0].value = repairRate;
                option4.tooltip.formatter = '已完成次数：' + fix0(data.data.repairedCounts) + '<br/>' +
                    '报修次数：' + fix0(data.data.toRepairCounts) + '<br/>' +
                    '维修完成率：' + fix2(repairRate) + '%';
                option1.series[2].data[1].value = 100 - inspectionRate;
                option2.series[2].data[1].value = 100 - compulsoryRate;
                option3.series[2].data[1].value = 100 - upkeepRate;
                option4.series[2].data[1].value = 100 - repairRate;
                numAnimate({
                    el: month.find('.value').eq(0),
                    newNum: parseFloat(inspectionRate),
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: month.find('.value').eq(1),
                    newNum: parseFloat(compulsoryRate),
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: month.find('.value').eq(2),
                    newNum: parseFloat(upkeepRate),
                    fixNum: 2,
                    unit: '%'
                });
                numAnimate({
                    el: month.find('.value').eq(3),
                    newNum: parseFloat(repairRate),
                    fixNum: 2,
                    unit: '%'
                });

                chartMonth0.setOption(option1);
                chartMonth1.setOption(option2);
                chartMonth2.setOption(option3);
                chartMonth3.setOption(option4);
                initStatus.detailStatus.queryMonthTotal = true;
            }, true);

        }

        /* 负荷率统计 */
        function queryUsageRate(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/usage-rate', 'post', parameters, function (data) {
                usageJson = data.data.list;
                for (var i = 0; i < usageJson.length; i++) {
                    optionOpen.yAxis[0].data[i] = usageJson[i].name;
                    optionOpen.series[0].data[i].name = usageJson[i].name;
                    optionOpen.series[0].data[i].value = fix2(usageJson[i].usageRate);
                }
                var newOption = $.extend(true, {}, optionOpen);
                if (typeof param.dataIndex === 'number') {
                    newOption.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;
                }
                chartOpen.setOption(newOption);
                initStatus.detailStatus.queryUsageRate = true;

                /* 服务人次 */
                peopleJson = data.data.all;
                numAnimate({
                    el: $('#servicePerson'),
                    newNum: parseInt(peopleJson.total),
                    unit: ''
                }, resizeLayout);
                var servicePersonYoyEl = $('#servicePersonYoy');
                numAnimate({
                    el: servicePersonYoyEl,
                    newNum: Math.abs(parseFloat(peopleJson.usedTimeYoy)),
                    unit: '%',
                    fixNum: 2
                }, resizeLayout);
                if (peopleJson.usedTimeYoy > 0) {
                    servicePersonYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_up.png');
                } else if (peopleJson.usedTimeYoy < 0) {
                    servicePersonYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_down.png');
                } else {
                    servicePersonYoyEl.prev().attr('src', basePath + '/plugins/charts/images/arrow_zero.png');
                }
                for (var i = 0; i < usageJson.length; i++) {
                    optionServicePerson.series[0].data[i].name = usageJson[i].name;
                    optionServicePerson.series[0].data[i].value = usageJson[i].usedCounts;
                }
                var newOption = $.extend(true, {}, optionServicePerson);
                if (typeof param.dataIndex === 'number') {
                    newOption.series[0].data[param.dataIndex].selected = true;
                    newOption.series[0].data[param.dataIndex].itemStyle.normal.color = selectedColor;
                    newOption.series[0].label.normal.formatter = function (params) {
                        if (params.dataIndex === 2) {
                            return usageJson[param.dataIndex].name;
                        } else if (params.dataIndex === 4) {
                            return (optionServicePerson.series[0].data[param.dataIndex].value || 0) + '次';
                        } else {
                            return '';
                        }
                    };
                }
                chartServicePerson.setOption(newOption);
                initStatus.detailStatus.queryDevicePersonInfo = true;
            }, true);

        }

        /* 警示事项 */
        function queryWarning(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/warning', 'post', parameters, function (data) {
                if (data.ret) {
                    numAnimate({
                        el: $('#exigencyRepair'),
                        newNum: parseInt(data.data.exigencyRepairCounts || 0)
                    });
                    numAnimate({
                        el: $('#highRiskRepair'),
                        newNum: parseInt(data.data.highRiskRepairCounts || 0)
                    });
                    numAnimate({
                        el: $('#planCompulsory'),
                        newNum: parseInt(data.data.planCompulsoryCounts || 0)
                    });
                    numAnimate({
                        el: $('#planUpkeep'),
                        newNum: parseInt(data.data.planUpkeepCounts || 0)
                    });
                    numAnimate({
                        el: $('#planSchedule'),
                        newNum: parseInt(data.data.toDoCounts || 0)
                    });
                }
                initStatus.detailStatus.queryWarning = true;
            }, true);
        }

        /* 警示列表 */
        function queryWarningList(tag, parameters) {
            publicAjax(basePath + '/charts/hospital/overview/warning-list', 'post', {tag: tag}, function(data){
                waringLis[tag] = {status: true, list: []};
                if (data.ret) {
                    var table = null;
                    var theadStr = '';
                    var tbodyStr = '';
                    if (tag === 1) {
                        waringLis[1].list.daiban = {};
                        waringLis[1].list.other = {};
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>所属科室-设备名称</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>报修时间</th>' +
                            '<th>维修商</th>' +
                            '<th>故障描述</th>' +
                            '<th>故障时间</th>' +
                            '<th>责任人</th>' +
                            '</tr>';
                        var iconStr;
                        for (var i = 0; i < data.data.list.length; i++) {
                            if (data.data.list[i].dispatchStatusItem === '已报修') {
                                if (!waringLis[1].list.daiban[data.data.list[i].repairTime]) {
                                    waringLis[1].list.daiban[data.data.list[i].repairTime] = [];
                                }
                                /* 闪烁图标 */
                                iconStr = getRepairIcon('repair', data.data.list[i].warn, true, data.data.list[i]);
                                waringLis[1].list.daiban[data.data.list[i].repairTime].push('<li data-repair-id="'+data.data.list[i].maintenanceId+'">' + iconStr +
                                    '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                    (data.data.list[i].name || '') + getStatus(data.data.list[i].repairStatus) +
                                    ' ' + (data.data.list[i].responsible || '') + '  ' +
                                    '已故障' + min2bigger(data.data.list[i].haveFaultMin).all +
                                    '</span>' +
                                    '</li>');
                            } else {
                                if (!waringLis[1].list.other[data.data.list[i].repairTime]) {
                                    waringLis[1].list.other[data.data.list[i].repairTime] = [];
                                }
                                iconStr = getRepairIcon('repair', data.data.list[i].warn, false, data.data.list[i]);
                                waringLis[1].list.other[data.data.list[i].repairTime].push('<li data-repair-id="'+data.data.list[i].maintenanceId+'">' + iconStr +
                                    '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                    (data.data.list[i].name || '') + getStatus(data.data.list[i].repairStatus) +
                                    ' ' + (data.data.list[i].responsible || '') + '  ' +
                                    '已故障' + min2bigger(data.data.list[i].haveFaultMin).all +
                                    '</span>' +
                                    '</li>');
                            }
                            tbodyStr += '<tr>' +
                                '<td class="no-cal">' + iconStr + (i + 1) + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + fixStr(data.data.list[i].department) + '-' + fixStr(data.data.list[i].name) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].repairTime || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].serviceProvider || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].faultDescription || '') + '</td>' +
                                '<td class="no-cal">' + fix2(min2bigger(data.data.list[i].haveFaultMin).value) + min2bigger(data.data.list[i].haveFaultMin || 0).unit + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].responsible || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table1');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table1', true);
                    } else if (tag === 2) {
                        waringLis[1].list.gaowei = {};
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>所属科室-设备名称</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>报修时间</th>' +
                            '<th>维修商</th>' +
                            '<th>故障描述</th>' +
                            '<th>故障时间</th>' +
                            '<th>责任人</th>' +
                            '</tr>';
                        var iconStr;
                        for (var i = 0; i < data.data.list.length; i++) {
                            if (data.data.list[i].dispatchStatusItem === '已报修') {
                                if (!waringLis[1].list.gaowei[data.data.list[i].repairTime]) {
                                    waringLis[1].list.gaowei[data.data.list[i].repairTime] = [];
                                }
                                iconStr = getRepairIcon('hitch', data.data.list[i].warn, true, data.data.list[i]);
                                waringLis[1].list.gaowei[data.data.list[i].repairTime].push('<li data-repair-id="'+data.data.list[i].maintenanceId+'">' + iconStr +
                                    '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                    (data.data.list[i].name || '') + getStatus(data.data.list[i].repairStatus) +
                                    ' ' + (data.data.list[i].responsible || '') + '  ' +
                                    '已故障' + min2bigger(data.data.list[i].haveFaultMin).all +
                                    '</span>' +
                                    '</li>');
                            } else {
                                iconStr = getRepairIcon('hitch', data.data.list[i].warn, false, data.data.list[i]);
                                waringLis[tag].list.push('<li>' + iconStr +
                                    '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                    (data.data.list[i].name || '') + getStatus(data.data.list[i].repairStatus) +
                                    ' ' + (data.data.list[i].responsible || '') + '  ' +
                                    '已故障' + min2bigger(data.data.list[i].haveFaultMin).all +
                                    '</span>' +
                                    '</li>');
                            }
                            tbodyStr += '<tr>' +
                                '<td class="no-cal">' + iconStr + (i + 1) + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + fixStr(data.data.list[i].department) + '-' + fixStr(data.data.list[i].name) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].repairTime || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].serviceProvider || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].faultDescription || '') + '</td>' +
                                '<td class="no-cal text-right">' + min2bigger(data.data.list[i].haveFaultMin).value + min2bigger(data.data.list[i].haveFaultMin).unit + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].responsible || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table2');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table2', true);
                    } else if (tag === 3) {
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>所属科室-设备名称</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>责任人</th>' +
                            '<th>上次强检时间</th>' +
                            '<th>下次强检时间</th>' +
                            '</tr>';
                        for (var i = 0; i < data.data.list.length; i++) {
                            waringLis[tag].list.push('<li>' +
                                '<i style="'+getIconStyle('force', data.data.list[i].warn)+'"></i>' +
                                '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                (data.data.list[i].name || '') + ' ' + (data.data.list[i].planCompulsoryDate || '') +
                                ' ' + (data.data.list[i].responsible || '') +
                                '</span>' +
                                '</li>');
                            tbodyStr += '<tr>' +
                                '<td class="no-cal"><i style="'+getIconStyle('force', data.data.list[i].warn)+'"></i>' + (i + 1) + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + (data.data.list[i].name || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].responsible || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].lastCompulsoryDate || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].planCompulsoryDate || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table3');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table3', true);
                    } else if (tag === 4) {
                        data.data.list = [];    // 没有召回，修改成0条记录
                        numAnimate({
                            el: $('#recall'),
                            newNum: data.data.list.length
                        });
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>所属科室-设备名称</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>厂商</th>' +
                            '<th>生产日期</th>' +
                            '<th>召回原因</th>' +
                            '<th>召回发布日期</th>' +
                            '<th>责任人</th>' +
                            '</tr>';
                        for (var i = 0; i < data.data.list.length; i++) {
                            waringLis[tag].list.push('<li>' +
                                '<i style="'+getIconStyle('recall', data.data.list[i].warn)+'"></i>' +
                                '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                (data.data.list[i].name || '') + ' ' + (data.data.list[i].planInspectionDate || '') +
                                ' ' + (data.data.list[i].responsible || '') +
                                '</span>' +
                                '</li>');
                            tbodyStr += '<tr>' +
                                '<td class="no-cal"><i style="'+getIconStyle('recall', data.data.list[i].warn)+'"></i>' + (i + 1) + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + fixStr(data.data.list[i].department) + '-' + fixStr(data.data.list[i].name) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].manufacturer || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].scrq || '2016-01-20') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].faultDescription || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].scrapTime || '2018-02-01') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].responsible || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table4');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table4', true);
                    } else if (tag === 5) {
                        numAnimate({
                            el: $('#planInspection'),
                            newNum: parseInt(data.data.list.length || 0)
                        });
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>所属科室-设备名称</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>参数名称</th>' +
                            '<th>参数数值</th>' +
                            '<th>报警等级</th>' +
                            '<th>报警时间</th>' +
                            '<th>处理次数</th>' +
                            '</tr>';
                        for (var i = 0; i < data.data.list.length; i++) {
                            waringLis[tag].list.push('<li>' +
                                '<i'+(data.data.list === '已处理' ? '' : ' class="blink"')+' onclick="canshu(this)" data-json=\''+JSON.stringify(data.data.list[i])+'\' style="'+getIconStyle('monitor', data.data.list[i].warn)+'"></i>' +
                                '<span showTitle>' + data.data.list[i].content + '</span>' +
                                '</li>');
                            tbodyStr += '<tr>' +
                                '<td class="no-cal"><i'+(data.data.list === '已处理' ? '' : ' class="blink"')+' onclick="canshu(this)" data-json=\''+JSON.stringify(data.data.list[i])+'\' style="'+getIconStyle('monitor', data.data.list[i].warn)+'"></i>' + (i + 1) + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + (data.data.list[i].department || '') + '-' +  (data.data.list[i].name || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].parameterName || '') + '</td>' +
                                '<td class="avg-2 text-right">' + fix2(data.data.list[i].parameterValue) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].policeLevel || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].createTime || '') + '</td>' +
                                '<td class="total-2 text-right">' + (data.data.list[i].proccessNum || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table5');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table5', true);
                    } else if (tag === 6) {
                        theadStr += '<tr>' +
                            '<th>#</th>' +
                            '<th>设备名称</th>' +
                            '<th>所属科室</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>服务商</th>' +
                            '<th>责任人</th>' +
                            '<th>上次保养时间</th>' +
                            '<th>下次保养时间</th>' +
                            '</tr>';
                        for (var i = 0; i < data.data.list.length; i++) {
                            waringLis[tag].list.push('<li>' +
                                '<i style="'+getIconStyle('upkeep', data.data.list[i].warn)+'"></i>' +
                                '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                (data.data.list[i].name || '') + ' ' + (data.data.list[i].planUpkeepDate || '') +
                                ' ' + (data.data.list[i].responsible || '') +
                                '</span>' +
                                '</li>');
                            tbodyStr += '<tr>' +
                                '<td class="no-cal"><i style="'+getIconStyle('upkeep', data.data.list[i].warn)+'"></i>' + (i + 1)  + '</td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + (data.data.list[i].name || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].department || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].serviceProvider || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].responsible || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].lastUpkeepDate || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].planUpkeepDate || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table6');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table6', true);
                    } else if (tag === 7) {
                        theadStr += '<tr>' +
                            '<th>#<input class="table-inline-checkbox" name="total" type="checkbox"></th>' +
                            '<th>设备名称</th>' +
                            '<th>所属科室</th>' +
                            '<th>设备型号</th>' +
                            '<th>年限指数</th>' +
                            '<th>类型</th>' +
                            '</tr>';
                        for (var i = 0; i < data.data.list.length; i++) {
                            waringLis[tag].list.push('<li>' +
                                getRepairIcon(data.data.list[i].type=='保养'?'upkeep':'repair', data.data.list[i].warn, true, data.data.list[i]) +
                                '<span showTitle>' + (data.data.list[i].department ? (data.data.list[i].department+'：'):'') +
                                (data.data.list[i].name || '') + ' 需 ' + (data.data.list[i].status === '未指派' ? '指派' : (data.data.list[i].type || '') + '评价') +
                                '</span>' +
                                '</li>');
                            tbodyStr += '<tr>' +
                                '<td class="no-cal" style="padding-right: 0.5rem;">' +
                                    getRepairIcon(data.data.list[i].type=='保养'?'upkeep':'repair', data.data.list[i].warn, true, data.data.list[i]) +
                                    (i + 1) + '<input class="table-inline-checkbox" name="schedule" type="checkbox"></td>' +
                                '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + (data.data.list[i].name || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].department || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                                '<td class="avg-1 text-right">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].type || '') + '</td>' +
                                '</tr>';
                        }
                        table = $('#list-table7');
                        table.find('thead').html(theadStr);
                        table.find('tbody').html(tbodyStr);
                        calTableData('list-table7', true, '<button id="deal-checked" class="btn btn-info" style="padding: 2px 5px;">处理</button>');
                        var checkbox = table.find('input[type="checkbox"]');
                        var checkall = table.find("input[type='checkbox'][name='total']");
                        var checkmy = table.find("input[type='checkbox'][name='schedule']");
                        checkbox.iCheck({
                            checkboxClass: 'icheckbox_flat-green',
                            radioClass: 'iradio_flat-green'
                        });
                        checkall.on('ifClicked', function(event){
                            checkmy.iCheck($(this).is(':checked') ? 'uncheck' : 'check');
                        });
                        checkmy.on('ifChecked', function(event){
                            var change = true;
                            checkmy.each(function(){
                                if($(this).is(':checked') == false){
                                    change = false;
                                }
                            });
                            if(change){
                                checkall.iCheck('check');
                            }
                        }).on('ifUnchecked', function(event){
                            if(checkall.is(":checked")){
                                checkall.iCheck('uncheck');
                            }
                        });
                        $('#deal-checked').click(function (){
                            var checkedBox = table.find('input[type="checkbox"][name="schedule"]:checked');
                            batchDealArr = [];
                            checkedBox.each(function () {
                                var obj = $(this);
                                var arr = obj.parent().prev('i').attr('onclick').split("'");
                                batchDealArr.push([arr[1], fixNull(arr[3]), fixNull(arr[5]), fixNull(arr[7]), fixNull(arr[9]), fixNull(arr[11])]);
                            });
                            dealBatchDeal();
                        });
                    }
                }
                initStatus.detailStatus['queryWarningList' + tag] = true;
                setScroll();
            }, true);
        }
        var repaireTimer = null;
        var otherTimer = null;
        function setScroll(status) {
            if (status || (waringLis[1].status && waringLis[2].status && waringLis[3].status && waringLis[4].status && waringLis[5].status && waringLis[6].status && waringLis[7].status)) {
                var str1 = '';
                var str1Arr = [];
                var str2 = '';
                var str2Arr = [];
                var count = 0;
                for (var key in waringLis[1].list.daiban) {
                    count += waringLis[1].list.daiban[key].length;
                }
                for (var key in waringLis[1].list.other) {
                    count += waringLis[1].list.other[key].length;
                }
                for (var key in waringLis[1].list.gaowei) {
                    count += waringLis[1].list.gaowei[key].length;
                }
                var showCount1 = count > warningCount ? warningCount : count;
                var showCount2 = warningCount - showCount1;
                for(var key in waringLis) {
                    if (key === '1') {
                        /* 紧急待办 */
                        var keyArr = [];
                        for (var key2 in waringLis[key].list.daiban) {
                            keyArr.push(key2);
                        }
                        keyArr.sort(function(a, b) { return a - b;});
                        for (var i = 0; i < keyArr.length; i++) {
                            for (var j = 0; j < waringLis[key].list.daiban[keyArr[i]].length; j++) {
                                str1Arr.push(waringLis[key].list.daiban[keyArr[i]][j]);
                            }
                        }
                        /* 紧急其他 */
                        keyArr = [];
                        for (var key2 in waringLis[key].list.other) {
                            keyArr.push(key2);
                        }
                        keyArr.sort(function(a, b) { return a - b; });
                        for (var i = 0; i < keyArr.length; i++) {
                            for (var j = 0; j < waringLis[key].list.other[keyArr[i]].length; j++) {
                                str1Arr.push(waringLis[key].list.other[keyArr[i]][j]);
                            }
                        }
                        waringLis[key].list2 = $.extend([], str1Arr);
                        /* 高危待办 */
                        keyArr = [];
                        waringLis[2].list2 = [];
                        for (var key2 in waringLis[key].list.gaowei) {
                            keyArr.push(key2);
                        }
                        keyArr.sort(function(a, b) { return a - b; });
                        for (var i = 0; i < keyArr.length; i++) {
                            for (var j = 0; j < waringLis[key].list.gaowei[keyArr[i]].length; j++) {
                                str1Arr.push(waringLis[key].list.gaowei[keyArr[i]][j]);
                                waringLis[2].list2.push(waringLis[key].list.gaowei[keyArr[i]][j]);
                            }
                        }
                    } else {
                        for (var i = 0; i < (waringLis[key].list.length > 5 ? 5 : waringLis[key].list.length); i++) {
                            str2Arr.push(waringLis[key].list[i]);
                        }
                    }
                }

                for(var i = 0; i < str1Arr.length + (showCount1 > warningCount ? showCount1 : 0); i++) {
                    str1 += str1Arr[i % str1Arr.length];
                }
                for(var i = 0; i < str2Arr.length + (str2Arr.length > showCount2 ? showCount2 : 0); i++) {
                    str2 += str2Arr[i % str2Arr.length];
                }
                repairList.html(str1);
                otherList.html(str2);
                var height = 0.8 * rem + 1;
                repairList.parent().height(height * showCount1);
                otherList.parent().height(height * showCount2);
                repairList.css('margin-top', 0);
                clearInterval(repaireTimer);
                otherList.css('margin-top', 0);
                clearInterval(otherTimer);
                var count1 = 0;
                var count2 = 0;
                var length1 = repairList.find('li').length;
                var length2 = otherList.find('li').length;

                if (length1 > warningCount) {
                    repaireTimer = setInterval(function () {
                        count1++;
                        repairList.animate({
                            marginTop: -(height * count1)
                        }, 2000, function (){
                            if (count1 >= length1 - showCount1) {
                                count1 = 0;
                                repairList.css('margin-top', 0);
                            }
                        });
                    }, 1000 * 10);
                }
                if (length2 > showCount2) {
                    otherTimer = setInterval(function () {
                        count2++;
                        otherList.animate({
                            marginTop: -(height * count2)
                        }, 2000, function () {
                            if (count2 >= length2 - showCount2) {
                                count2 = 0;
                                otherList.css('margin-top', 0);
                            }
                        });
                    }, 1000 * 10);
                }
                $('.warning-list').find('[showTitle]').each(function(){
                    $(this).attr('title', $(this).text());
                });

                loading(true);
            }
        }
        function getRepairIcon(code, warn, isClick, data) {
            var classStr = '',
                clickStr = '',
                title = '';
            var type = data.dispatchStatusItem === '已报修' ? '指派' : (code === 'repair' || code === 'hitch' ? '维修' : '保养');
            if (isClick) {
                clickStr = ' onclick="score(\''+(data.status === '未指派' ? '指派' : (data.type || type))+'\',\''+data.dispatchId+'\',\''+data.maintenanceId+'\',\''+data.id+'\',\''+data.maintenanceType+'\',\''+data.photos+'\')"';
                classStr = ' class="blink"';
            }
            /* 标题 */
            if (data.dispatchStatusItem === '已报修') {
                title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，点击指派维修商"';
            } else if (data.dispatchStatusItem === '已处理') {
                title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，维修商正在安排工程师"';
            } else if (data.dispatchStatusItem === '已指派') {
                title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，工程师已接到任务"';
            } else if (data.dispatchStatusItem){
                title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，工程师' + fixStr(data.dispatchStatusItem) + '"';
            } else if (data.type === '维修') {
                if (data.status === '未指派') {
                    title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，点击指派维修商"';
                } else {
                    title = ' title="设备故障' + min2bigger(data.haveFaultMin || 0).all + '，工程师抢修完毕，点击给工程师服务点个赞..."';
                }
            } else if (data.type === '保养') {
                title = ' title="设备保养完成，点击给工程师服务点个赞..."';
            }
            var str = '<i' + classStr + title +
                ' style="background-image:url(<%=basePath%>/plugins/charts/images/web/' + code + (warn ? '-' + warn : '') + '.png);"' +
                clickStr + '></i>';
            return str;
        }
        function getIconStyle(code, warn) {
            return 'background-image:url(<%=basePath%>/plugins/charts/images/web/' + code + (warn ? '-' + warn : '') + '.png);'
        }
        function getStatus(status) {
            if (status === '3001') {
                return ' 已报修';
            } else if (status === '3002') {
                return ' 已处理';
            } else if (status === '3003') {
                return ' 已指派';
            } else if (status === '3004') {
                return ' 维修中';
            } else if (status === '3005') {
                return ' 维修完';
            }
        }

        /* 事件提醒 新闻 */
        function queryNewList(parameters) {
            /* 聊天记录 */
            publicAjax(basePath + '/charts/hospital/overview/repair-chat', 'post', {}, function(data){
                if (data.ret) {
                    var list = data.data.list;
                    var chatLength = 0;
                    var str = '';
                    for(var i = 0; i < list.length; i++) {
                        if (list[i].display) {
                            var isBlink = '';
                            if (window.chatGroupIdList && chatGroupIdList[list[i].groupId] && (Date.parse(new Date()) - chatGroupIdList[list[i].groupId] < 30000)) {
                                isBlink = ' class="blink1"'
                            }
                            str += '<li id="group-' + list[i].groupId + '"'+ isBlink +'>' +
                                '<div class="chat-icon"><i class="fa fa-wechat"></i><span class="spanTitle group-name" ' +
                                'onclick="gotoChat(' + list[i].groupId + ')" ' +
                                'data-client-id="' + data.data.clientId + '" ' +
                                'data-client-name="' + data.data.clientName + '" ' +
                                'data-group-id="' + list[i].groupId + '" ' +
                                'data-group-name="' + list[i].groupName + '" ' +
                                'data-from-id="' + list[i].repairId + '" ' +
                                'data-total-page="' + list[i].totalPage + '" ' +
                                'data-total-size="' + list[i].totalSize + '">'
                                + list[i].groupName + '</span>：' +
                                '</div>' +
                                '<div class="chat-wrapper"><div class="chat-content" data-group-id="' + list[i].groupId + '">' +
                                '<span>' + list[i].content + '</span>' +
                                '<span>' + list[i].content + '</span>' +
                                '</div></div>' +
                                '</li>';
                            chatLength++;
                        }

                    }
                    chatList.parent().height((rem * 0.8) * (chatLength > 4 ? 4 : chatLength));
                    webSocketChat(data.data.clientId, data.data.clientName);
                    chatList.html(str);
                    /* 聊天聊天记录横向滚动 */
                    timerChatList = {};
                    chatList.find('.chat-content').each(function (index) {
                        var obj = $(this);
                        var groupId = $(this).data().groupId;
                        var margin = 0;
                        var width = obj.width() / 2;
                        var showWidth = obj.parent().width();
                        if (showWidth >= width) {
                            obj.find('span').eq(1).remove();
                            return;
                        }
                        clearInterval(timerChatList[groupId]);
                        function run() {
                            timerChatList[groupId] = setInterval(function () {
                                margin--;
                                obj.css('margin-left', margin);
                                if (margin <= (0 - width)) {
                                    obj.css('margin-left', 0);
                                    margin = 0;
                                }
                            }, 26);
                        }
                        run();
                    });

                    var count = 0;
                    newList.css('margin-top', 0);
                    var showCount = parseInt(totalCount / 2) - (chatLength > 4 ? 4 : chatLength);
                    var height = eventList.find('li').height();
                    eventList.height(height * showCount);
                    if (!window.dsfsdfsf) {
                        newList.append(newList.find('li:lt(' + showCount + ')').clone());
                        window.dsfsdfsf = true;
                    }
                    var length = newList.find('li').length - showCount;
                    clearTimeout(newListTimer);
                    newListTimer = setInterval(function () {
                        count++;
                        newList.animate({
                            marginTop: - (height * count)
                        }, 2000, function (){
                            if (count >= length) {
                                count = 0;
                                newList.css('margin-top', 0);
                            }
                        });
                    }, 1000 * 10);
                } else {
                    flavrShowByTime(data.msg, null, 'danger', false);
                }
                initStatus.detailStatus.queryNewList = true;
            }, true, false, {async:false});
        }

        /* 调用聊天插件 */
        function gotoChat(groupId) {
            queryNewList();
            var res = $('#group-' + groupId).find('.group-name').data();
            $('#chat-box').chatBox({
                clientId: res.clientId,
                clientName: res.clientName,
                groupId: res.groupId,
                groupName: res.groupName,
                fromId: res.fromId,
                totalPage: res.totalPage,
                totalSize: res.totalSize
            });
        }

        /* 重点设备详情 */
        function queryKeyPointAssets(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/key-point-assets', 'post', param, function (data) {
                var theadStr = '';
                theadStr += '<tr>' +
                    '<th>#</th>' +
                    '<th>设备名称</th>' +
                    '<th>所属科室</th>' +
                    '<th>设备类型</th>' +
                    '<th>设备型号</th>' +
                    '<th>设备厂家</th>' +
                    '<th>启用日期</th>' +
                    '<th>设备金额(万元)</th>' +
                    '<th>年限指数</th>' +
                    '</tr>';
                var tbodyStr = '';
                for (var i = 0; i < data.data.keyPointAssets.length; i++) {
                    tbodyStr += '<tr>' +
                        '<td class="no-cal">' + (i + 1) + '</td>' +
                        '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.keyPointAssets[i].id+'\')">' + (data.data.keyPointAssets[i].name || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.keyPointAssets[i].department || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.keyPointAssets[i].firstTypeName || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.keyPointAssets[i].modalName || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.keyPointAssets[i].manufacturer || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.keyPointAssets[i].enableDate || '') + '</td>' +
                        '<td class="total-1 text-right">' + fix2(data.data.keyPointAssets[i].price / CONST) + '</td>' +
                        '<td class="avg-1 text-right">' + fix2(data.data.keyPointAssets[i].ageLimitMeasure) + '</td>' +
                        '</tr>';
                }
                $('#asset-title').html('重点设备');
                table = $('#asset-table');
                table.find('thead').html(theadStr);
                table.find('tbody').html(tbodyStr);
                calTableData('asset-table', true);
            }, true);
        }

        /* 年度设备详情 */
        function queryYearAssets(parameters) {
            publicAjax(basePath + '/charts/hospital/overview/statistics', 'post', parameters, function (data) {
                data.data.list.calTotal();
                var title = $('#asset-title');
                var theadStr = '';
                theadStr += '<tr>' +
                    '<th>#</th>' +
                    '<th>设备名称</th>' +
                    '<th>所属科室</th>' +
                    '<th>设备类型</th>' +
                    '<th>设备型号</th>' +
                    '<th>年限指数</th>' +
                    (function(){
                        if (parameters.statisticsType === 0) {
                            title.html('巡检详情');
                            return '<th>计划巡检时间</th>' +
                                '<th>实际巡检时间</th>';
                        } else if (parameters.statisticsType === 1) {
                            title.html('强检详情');
                            return '<th>计划强检时间</th>' +
                                '<th>实际强检时间</th>';
                        } else if (parameters.statisticsType === 2) {
                            title.html('保养详情');
                            return '<th>计划保养时间</th>' +
                                '<th>实际保养时间</th>';
                        } else  if (parameters.statisticsType === 3) {
                            title.html('维修详情');
                            return '<th>报修时间</th>' +
                            '<th>故障描述</th>' +
                            '<th>响应时间</th>' +
                            '<th>故障时间</th>' +
                            '<th>维修商</th>' +
                            '<th>维修大小</th>' +
                            '<th>维修时间</th>' +
                            '<th>维修费用(元)</th>';
                        }
                    })() +
                    '</tr>';
                var tbodyStr = '';
                for (var i = 0; i < data.data.list.length; i++) {
                    tbodyStr += '<tr>' +
                        '<td class="no-cal">' +
                        (function (x) {
                            if (parameters.statisticsType === 3) {
                                return data.data.list[x].maintainSize ?
                                    '<i style="background-image:url(<%=basePath%>/plugins/charts/images/web/repaired.png);background-size: contain;" title="已完成"></i>' :
                                    '<i style="background-image:url(<%=basePath%>/plugins/charts/images/web/notrepaired.png);background-size: contain;" title="未完成"></i>';
                            }
                            return '';
                        })(i) + (i + 1) + '</td>' +
                        '<td class="no-cal spanTitle" onclick="winOpen(\'/charts/overview/assets/page?deviceId='+data.data.list[i].id+'\')">' + (data.data.list[i].name || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.list[i].department || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.list[i].firstTypeName || '') + '</td>' +
                        '<td class="no-cal">' + (data.data.list[i].modalName || '') + '</td>' +
                        '<td class="avg-1 no-cal">' + fix2(data.data.list[i].ageLimitMeasure) + '</td>' +
                        (function(){
                            if (parameters.statisticsType === 3) {
                                return '<td class="no-cal">' + (data.data.list[i].repairTime || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].faultDescription || '') + '</td>' +
                                '<td class="no-cal text-right">' + min2bigger(data.data.list[i].responseMin).value + min2bigger(data.data.list[i].responseMin).unit + '</td>' +
                                '<td class="no-cal text-right">' + min2bigger(data.data.list[i].faultMin).value + min2bigger(data.data.list[i].faultMin).unit + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].maintainer || '') + '</td>' +
                                '<td class="no-cal">' + (data.data.list[i].maintainSize || '') + '</td>' +
                                '<td class="no-cal text-right">' + min2bigger(data.data.list[i].repairUsedMin).value + min2bigger(data.data.list[i].repairUsedMin).unit + '</td>' +
                                '<td class="total-1 text-right">' + fix2(data.data.list[i].repairCost/100) + '</td>';
                            } else {
                                return '<td class="no-cal">' + (data.data.list[i].dateExpected || '') + '</td>' +
                                    '<td class="no-cal">' + (data.data.list[i].dateActual || '') + '</td>';
                            }
                        })() +
                        '</tr>';
                }
                table = $('#asset-table');
                table.find('thead').html(theadStr);
                table.find('tbody').html(tbodyStr);
                table.find('tfoot').html(
                    '<tr>' +
                    '<td>总计</td>' +
                    '<td>' + data.data.list.length + '</td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    '<td></td>' +
                    (parameters.statisticsType === 3
                        ? ('<td></td>' +
                        '<td></td>' +
                        '<td></td>' +
                        '<td></td>' +
                        '<td></td>' +
                        '<td>' + fix2(data.data.list[-1].repairCost / 100) + '</td>')
                        : '') +
                    '</tr>'
                );
                setTimeout(function () {
                    if (data.data.list.length > 200) {
                        table.tableHeadFixer({'head': true, 'foot': true});
                    } else {
                        table.tableHeadFixer({'left': 2, 'head': true, 'foot': true});
                    }
                }, 5);
                // calTableData('asset-table', true);
            }, true);
        }

        function initBindEvent() {
            var title = $('#list-title');
            var listModel = $('#list-model');
            var iconFrame = $('.icon-frame');

            iconFrame.click(function (){
                var index = $(this).index('.icon-frame');
                if($(this).hasClass('active')) {
                    $(this).removeClass('active');
                    closeModel();
                } else {
                    iconFrame.removeClass('active');
                    $(this).addClass('active');
                    openModel(index);
                }
            });
            $('#list-close').click(closeModel);
            $('#deviceCount').click(function(){
                queryKeyPointAssets();
                $('#asset-model').show();
            });
            $('#serviceTime').click(function(){
                $('#asset-model').show();
                queryYearAssets($.extend({}, param, {dateType: 1,statisticsType:3}));
            });
            $('#asset-close').click(function() {
                $('#asset-model').hide();
            });
            $('.month-chart').click(function(){
                var index = $(this).index('.month-chart');
                queryYearAssets($.extend({}, param, {dateType: 2,statisticsType: index}));
                $('#asset-model').show();
            });

            function openModel(index) {
                if (index === 0) {
                    title.text('紧急维修');
                } else if (index === 1) {
                    title.text('择期维修');
                } else if (index === 2) {
                    title.text('强检提醒');
                } else if (index === 3) {
                    title.text('召回事件');
                } else if (index === 4) {
                    title.text('设备监控');
                } else if (index === 5) {
                    title.text('保养提醒');
                } else if (index === 6) {
                    title.text('待办事项');
                }
                $('#list-model').find('.list-table').hide().eq(index).show();
                $('#list-model').show().find('.list-table').trigger('scroll');

                /* 滚动列表变换 */
                var str = '';
                var forLength;
                if (index === 0) {
                    forLength = waringLis[index + 1].list2.length <= warningCount ? waringLis[index + 1].list2.length : waringLis[index + 1].list2.length + warningCount;
                    for (var i = 0; i < forLength; i++) {
                        str += waringLis[index + 1].list2[i % waringLis[index + 1].list2.length];
                    }
                } else if (index === 1) {
                    var list = $.extend([], waringLis[index + 1].list2);
                    for (var i = 0; i < waringLis[index + 1].list.length; i++) {
                        list.push(waringLis[index + 1].list[i]);
                    }
                    forLength = list.length <= warningCount ? list.length : list.length + warningCount;
                    for (var i = 0; i < forLength; i++) {
                        str += list[i % list.length];
                    }
                } else {
                    forLength = waringLis[index + 1].list.length <= warningCount ? waringLis[index + 1].list.length : waringLis[index + 1].list.length + warningCount;
                    for (var i = 0; i < forLength; i++) {
                        str += waringLis[index + 1].list[i % waringLis[index + 1].list.length];
                    }
                }
                changeList.html(str).css('margin-top', 0);
                changeCount = 0;
                clearTimeout(changeTimer);
                var length = changeList.find('li').length;
                if (length > warningCount) {
                    changeTimer = setInterval(function () {
                        changeCount++;
                        changeList.animate({
                            marginTop: -(41 * changeCount)
                        }, 2000, function () {
                            if (changeCount >= length - warningCount) {
                                changeCount = 0;
                                changeList.css('margin-top', 0);
                            }
                        });
                    }, 1000 * 10);
                }
                repairList.parent().hide();
                otherList.parent().hide();
                changeList.parent().show();
            }

            function closeModel() {
                iconFrame.removeClass('active');
                $('#list-model').hide();
                $('#list-model').find('.list-table').hide();
                repairList.parent().show();
                otherList.parent().show();
                changeList.parent().hide();
            }
        }



        /* 每次维修气泡图 */
        /*var schema = [
            {name: 'agelimit', index: 0, text: '年限指数'},
            {name: 'price', index: 1, text: '设备金额'},
            {name: 'repairPrice', index: 2, text: '维修费用'}
        ];
        var optionRepair = {
            color: ['#31860f'],
            backgroundColor: '#373945',
            tooltip: {
                padding: 10,
                backgroundColor: '#222',
                borderColor: '#777',
                borderWidth: 1,
                formatter: function (obj) {
                    var value = obj.value;
                    return  value[3] + '：<br>'
                        + schema[0].text + '：' + fix2(value[0]) + '<br>'
                        + schema[1].text + '：' + fix2(value[1]) + '万元<br>'
                        + schema[2].text + '：' + fix2(value[2]/100) + '元<br>';
                }
            },
            dataZoom: [{
                type: 'inside',
                xAxisIndex: [0],
                start: 0,
                end: 100
            },
                {
                    type: 'inside',
                    yAxisIndex: [0],
                    start: 0,
                    end: 100
                }
            ],
            grid: {
                left: 20,
                right: 120,
                bottom: 40,
                containLabel: true
            },
            xAxis: {
                name: '年限指数',
                type: 'value',
                nameTextStyle: {
                    color: '#fff'
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#fff'
                    }
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        color: '#f00',
                        type: 'dashed'
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisTick: {
                    lineStyle: {
                        color: '#fff'
                    }
                }
            },
            yAxis: [{
                name: '设备金额',
                type: 'value',
                nameTextStyle: {
                    color: '#fff'
                },
                axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#fff'
                    }
                },
                splitLine: {
                    show: false,
                    lineStyle: {
                        color: '#f00',
                        type: 'dashed'
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#fff'
                    }
                },
                axisTick: {
                    lineStyle: {
                        color: '#fff'
                    }
                }
            }],
            visualMap: [
                {
                    show: false,
                    left: 'right',
                    bottom: '5%',
                    dimension: 2,
                    min: 0,
                    max: 50,
                    itemHeight: 120,
                    calculable: true,
                    precision: 0.1,
                    text: ['明暗：二氧化硫'],
                    textGap: 30,
                    textStyle: {
                        color: '#fff'
                    },
                    inRange: {
                        colorLightness: [1, 0.5]
                    },
                    outOfRange: {
                        color: ['rgba(255,255,255,.2)']
                    },
                    controller: {
                        inRange: {
                            color: ['#c23531']
                        },
                        outOfRange: {
                            color: ['#444']
                        }
                    }
                }
            ],
            series: [{
                name: '北京',
                type: 'scatter',
                itemStyle:  {
                    normal: {
                        opacity: 0.8,
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                },
                data: [],
                symbolSize: 35,
            }]
        };

        $.ajax({
            type: "POST",
            url: '<%=basePath%>/charts/hospital/overview/repair-bubble',
            data: {},
            dataType: "json",
            success: function (data) {
                var list = data.data.list || [];
                var optionData = [];
                for(var i = 0; i < list.length; i++) {
                    optionData.push([fixStr(list[i].ageLimitMeasure), fixStr(list[i].price/CONST), fix0(list[i].estimateTotalCost), fixStr(list[i].assetsName)]);
                }
                optionRepair.series[0].data = optionData;
                var chart = echarts.init($('#chartRepair')[0]);
                chart.setOption(optionRepair);
            }
        });*/

        /* 维修、保养评价 */
        function score(type, dispatchId, id, assetsId, maintenanceType, photos, isBatchDeal) {
            if (type == '保养') {
                $.upkeepScore(dispatchId, id, isBatchDeal);
            } else if (type == '维修') {
                $.repairScore(dispatchId, id, assetsId, maintenanceType, 'report', false, false, isBatchDeal);
            } else if (type == '指派') {
                $.appoint(id, assetsId, false, false, isBatchDeal);
            }
        }
        // 处理参数异常
        function canshu(obj) {
            var param = $(obj).data().json;
            $.canshu({
                assetsId: param.id,
                content: param.content,
                createTime: param.createTime,
                id: param.parameterEventId,
                parameterId: param.parameterId,
                parameterName: param.parameterName
            }, false);
        }
    </script>
    </body>
</fmt:bundle>
</html>
